import React from 'react';
import './loginStyle.less';
import { Card, Space, Button, Checkbox, Form, Input } from 'antd';
import { addCanvas } from '@/hoc/index.js';
import { useLogin } from '@/api/index';
import _ from 'lodash';
import { withRouter } from 'react-router-dom';
const onFinishFailed = (errorInfo: any) => {
  console.log('Failed:', errorInfo);
};
export function index(props: any) {
  const { history } = props;
  const onFinish = (values: any) => {
    // useLogin(values).then((res) => {
    //   console.log(res);
    // });
    sessionStorage.setItem('token', 'ADWADWAFCZxC');
    history.push('/home');
  };
  return (
    <div className="login1">
      <Card
        title="管理中心登录"
        style={{ width: 400 }}
        headStyle={{
          textAlign: 'center',
          fontSize: '20px',
          fontWeight: '600',
          color: '#fff',
        }}
        className="card1"
        bordered={false}
      >
        <Form
          name="basic"
          style={{ maxWidth: 600 }}
          initialValues={{ remember: true }}
          onFinish={_.debounce(onFinish, 1000)}
          onFinishFailed={onFinishFailed}
          autoComplete="off"
        >
          <Form.Item
            name="username"
            rules={[{ required: true, message: '请输入用户名' }]}
          >
            <Input />
          </Form.Item>

          <Form.Item
            name="password"
            rules={[{ required: true, message: '请输入密码' }]}
          >
            <Input.Password />
          </Form.Item>
          <Form.Item
            name="password"
            rules={[{ required: true, message: '请输入验证码' }]}
          >
            <Space direction="horizontal">
              <Input.Password />
              <img src="http://fangadmin.shbwyz.com/login/verfiy.html" alt="" />
            </Space>
          </Form.Item>
          <Form.Item>
            <Button type="primary" style={{ width: '100%' }} htmlType="submit">
              登录
            </Button>
          </Form.Item>
        </Form>
      </Card>
    </div>
  );
}

export default addCanvas(withRouter(index));
